<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2020/12/17
  Time: 19:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- 引入Bootstrap核心文件 -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- jQuery(Bootstrap的JavaScript插件需要引入jQuery，务必在bootstrap.min.js之前引入) -->
    <script src="js/jquery.min.js"></script>

    <!-- 包括所有已编译的JS插件 -->
    <script src="js/bootstrap.min.js"></script>
    <script type="text/javascript">
        function delMovies() {
            $("#movie-form").submit();
        }
        function searchMovies() {
            $("#from-movie").submit();
        }
    </script>
</head>

<body>
<h1 class="text-center pt-3 pb-3">电影列表</h1>

<div class="container">
    <div class="offset-md-2 col-md-8">
        <div class="row pl-3">
            <form class="form-inline" id="from-movie" action="/all_movies.action" method="post">
                <div class="form-group" style="font-size:18px; font-weight:lighter;">
                    <label>影片分类：</label>
                    <c:forEach items="${categories}" var="c">
                        <c:set var="status" value=""/>
                        <c:forEach items="${categoryIds}" var="a">
                            <c:if test="${c.categoryId == a}">
                                <c:set var="status" value="checked"/>
                            </c:if>
                        </c:forEach>
                        <input type="checkbox" name="categoryIds" class="form-check-input" value="${c.categoryId}" ${status}> ${c.categoryName}&nbsp;
                    </c:forEach>
                </div>

                &nbsp;&nbsp;
                <div class="form-group">
                    <button type="button" onclick="searchMovies()" class="btn btn-sm btn-outline-secondary">查询</button>
                </div>

                &nbsp;&nbsp;
                <div class="form-group">
                    <button type="button" onclick="window.open('/goto_add.action')" class="btn btn-sm btn-outline-secondary">增加影片</button>
                </div>

                &nbsp;&nbsp;
                <div class="form-group">
                    <button type="button" onclick="delMovies()" class="btn btn-sm btn-outline-secondary">批量删除</button>
                </div>
            </form>
        </div>
        <form id="movie-form" action="/del_movies.action" method="post">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <td>选项</td>
                    <td>编号</td>
                    <td>名称</td>
                    <td>类别</td>
                    <td>地区</td>
                    <td>票价</td>
                    <td>操作</td>
                </tr>
                </thead>

                <c:forEach items="${moviePage.movieList}" var="m">
                    <tr>
                        <td>
                            <input type="checkbox" class=""  name="id" value="${m.id}">
                        </td>
                        <td>${m.id}</td>
                        <td>${m.name}</td>
                        <td>
                            <c:forEach items="${m.categories}" var="c">
                                <a href="">${c.categoryName}</a> /
                            </c:forEach>
                        </td>
                        <td>${m.country.countryName}</td>
                        <td>${m.price}</td>
                        <td><a href="/goto_set.action?id=${m.id}" target="_blank">修改</a>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </form>

        <nav class="pb-5 pt-3">
            <ul class="pagination justify-content-center">
                <c:if test="${moviePage.pageNum == 1}" >
                    <li class="page-item disabled">
                        <a class="page-link disabled" href="#" tabindex="-1">首页</a>
                    </li>
                </c:if>
                <c:if test="${moviePage.pageNum > 1}">
                    <li class="page-item disabled">
                        <a class="page-link" href="/all_movies.action?pageNum=1&pageSize=${moviePage.pageSize}&categoryIds=${s}" tabindex="-1">首页</a>
                    </li>
                </c:if>
                <c:forEach begin="1" end="${moviePage.pageCount}" var="i">
                    <c:if test="${moviePage.pageNum == i}">
                        <li class="page-item active"><a class="page-link" href="#">${i}</a></li>
                    </c:if>
                    <c:if test="${moviePage.pageNum != i}">
                        <li class="page-item"><a class="page-link" href="/all_movies.action?pageNum=${i}&pageSize=${moviePage.pageSize}&categoryIds=${s}">${i}</a></li>
                    </c:if>
                </c:forEach>
                <c:if test="${moviePage.pageNum == moviePage.pageCount}">
                    <li class="page-item disabled"><a class="page-link" href="#">末页</a></li>
                </c:if>
                <c:if test="${moviePage.pageNum < moviePage.pageCount}">
                    <li class="page-item"><a class="page-link" href="/all_movies.action?pageNum=${moviePage.pageCount}&pageSize=${moviePage.pageSize}&categoryIds=${s}">末页</a></li>
                </c:if>
            </ul>
        </nav>

    </div>
</div>
</body>
</html>